package main

import "fmt"


func main() {
    Arr := []int{1, 3, 4, 6, 7, 9, 11, 12, 13, 18, 20, 40, 50, 66, 76, 78}
	fmt.Println(BinaSearch(Arr, 90))  //-1
}

//要点：数列必须是有序的 数列
func BinaSearch(aArr []int, item int) int {
	if len(aArr) == 0 {
		return -1
	}
	start, end := 0, len(aArr) - 1
	for start <= end {
		mid := start + (end - start) / 2
		if aArr[mid] == item {
			return mid
		} else if (item < aArr[mid]) {
			end = mid - 1
		} else {
			start = mid + 1
		}
	}
	return -1

}